import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

/**** 点检计划  */
//查询
export const getExceptionList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/pointCheckPlan/pagePointCheckPlanList`, {
    data
  });
};

// 删除
export const delExceptionList = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/pointCheckPlan/delByPlanNo/${data}`);
};

// 点检计划编码
export const getPlanCode = () => {
  return http.request("post", `/digitaltwins/api/v1/pointCheckPlan/getPointCheckPlanNo`);
};

// 上传图片moduleName
export const getModuleName = () => {
  return http.request("post", `/digitaltwins/api/v1/pointCheckPlan/getFileModelName`);
};

// 新增
export const addExceptionList = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/pointCheckPlan/savePointCheckPlan`, {
    data
  });
};

// 编辑
export const editExceptionList = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/pointCheckPlan/updatePointCheckPlan`, {
    data
  });
};

// 新增草稿
export const addExceptionDraft = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/pointCheckPlan/saveDraftPointCheckPlan`, {
    data
  });
};

// 编辑草稿
export const editExceptionDraft = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/pointCheckPlan/updateDraftPointCheckPlan`, {
    data
  });
};

// 详情
export const detailExceptionList = (data?: string) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/pointCheckPlan/getPointCheckPlanByPlanNo/${data}`);
};

// 取消
export const cancelExceptionList = (data?: string) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/pointCheckPlan/cancelPointCheckPlanByPlanNo/${data}`);
};

// 修改计划
export const editExceptionPlan = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/pointCheckPlan/updatePointPlan`, { data });
};

// 修改计划的执行周期
export const editExceptionPlanCycle = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/pointCheckPlan/updatePointPlan`, { data });
};

/**** 点检任务  */
//查询
export const getExceptionTaskList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/pointCheckTask/pagePointCheckTaskList`, {
    data
  });
};

// 上传图片moduleName
export const getTaskModuleName = () => {
  return http.request("post", `/digitaltwins/api/v1/pointCheckTask/getFileModelName`);
};

// 领取点检任务详情
export const detailCollectExceptionTask = (data?: string) => {
  return http.request<Record<string, any>>("get", `/digitaltwins/api/v1/pointCheckTask/getReceivePointCheckTask/${data}`);
};

// 领取点检任务
export const collectExceptionTask = (data?: string) => {
  return http.request<Record<string, any>>("get", `/digitaltwins/api/v1/pointCheckTask/receivePointCheckTask/${data}`);
};

// 根据运维组code获取运维人员列表
export const getOpsGroupList = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/opsGroup/getOperatorByCode/${data}`);
};

// 获取点检任务执行详情
export const detailExceptionTask = (data?: string) => {
  return http.request<Record<string, any>>("get", `/digitaltwins/api/v1/pointCheckTask/getExecutePointCheckTask/${data}`);
};

//转派
export const forwardExceptionTask = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/pointCheckTask/forwardTask`, {
    data
  });
};

// 完成任务并提交执行结果
export const finishExceptionTask = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/pointCheckTask/submitTask`, {
    data
  });
};

// 取消点检任务
export const cancelExceptionTask = (data?: string) => {
  return http.request<Record<string, any>>("get", `/digitaltwins/api/v1/pointCheckTask/cancelPointCheckTask/${data}`);
};

// 变更是否转维修任务
export const changeExceptionTaskStatus = (data?: string) => {
  return http.request<Record<string, any>>("get", `/digitaltwins/api/v1/pointCheckTask/transferMaintenanceTask/${data}`);
};
